#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>


int main()
{
  //pid_t pid;
  //printf("Before: pid is %d\n", getpid());
  //if ((pid=fork()) == -1)
  //{
  //  perror("fork()");
  //  exit(1);
  //}

  //printf("After:pid is %d, fork return %d\n", getpid(), pid);
  //sleep(1);
  //return 0;
  
  pid_t id = fork();
  if(id == 0)
  {
    //子进程
    int cnt = 3;
    while(cnt)
    {
      printf("我是一个子进程：pid: %d, ppid: %d\n", getpid(),getppid());     
      sleep(1);
    }

  }
  

  return 0;
}
